<!DOCTYPE HTML />
<html>
<head>
    <title>密码找回</title>
    <link href="/css/main.css" rel="stylesheet"/>
    <?php include_once("common/common_js.php") ?>
</head>
<body>
<?php include_once("common/banner.php"); ?>
<div class="warpper">
    <?php include_once("common/header.php"); ?>
    <div class="al">
        <h3>密码找回</h3>

        <div class="content">
            <form name="form1" action="/index.php/Passport/password" method="post">
                <?php if (array_key_exists("error", $view) && $view['error'] != "") {
                echo $view['error'];
            }?>
                <table>
                    <?php
                    if (array_key_exists("step", $view) && $view['step'] == "1") {
                    ?>
                    <tr>
                        <td width="250">第一步： 请输入用户名</td>
                        <td><input type="text" name="userName" id="userName" class="f_txt"/></td>
                        <td rowspan="4" style="text-align:center;">
                        </td>
                    </tr>
                    <?php } ?>
                    <?php
                       if (array_key_exists("step", $view) && $view['step'] == "2") {
                    ?>
                    <tr>
                        <td width="250">第二步：邮箱</td>
                        <td cols="2"><input name="email" id="email" type="text" class="f_txt"/>&nbsp;注：用于找回密码</td>
                    </tr>
                    <?php } ?>
                    <?php
                           if (array_key_exists("step", $view) && $view['step'] == "3") {
                    ?>
                    <tr>
                        <td width="250">第三步：请回答安全问题</td>
                        <td cols="2">
                            <?php if (array_key_exists("question", $view) && $view['question'] != "") {
                            echo $view['question'];
                        } ?>
                        </td>
                    </tr>
                    <tr>
                        <td>答案</td>
                        <td cols="2"><input name="answer" id="answer" type="text" class="f_txt"/></td>
                    </tr>
                    <?php } ?>
                    <?php
                    if (array_key_exists("step", $view) && $view['step'] == "4") {
                    ?>
                    <tr>
                        <td width="100%">恭喜您，密码已经被系统自动重置，请记住以下密码，重新登录</td>
                    </tr>
                    <tr>
                        <td style="font-size: 36px; color: red">
                            <?php if (array_key_exists("newPassword", $view) && $view['newPassword'] != "") {
                            echo $view['newPassword'];
                        } ?>
                        </td>
                    </tr>
                    <?php } ?>

                    <?php
                                                                   if (array_key_exists("step", $view) && $view['step'] != "4") {
                    ?>
                    <tr>
                        <td></td>
                        <td><input type="button" onclick="subm()" value="下一步" class="f_btn"/><input type="button"
                                                                                                    value="上一步"
                                                                                                    onclick="javascript:history.go(-1)"
                                                                                                    class="f_btn"/>
                        </td>
                    </tr>
                    <?php }?>
                </table>
            </form>
        </div>
    </div>
</div>
<script language="javascript">
    function subm() {
                    <?php
                                       if (array_key_exists("step", $view) && $view['step'] == "1") {
        ?>
        if ($("#userName").val() == "") {
            alert("请输入用户名");
            return false;
        }
        <?php } ?>
                    <?php
                                       if (array_key_exists("step", $view) && $view['step'] == "2") {
        ?>
        if ($("#email").val() == "") {
            alert("请输入邮箱地址");
            return false;
        }

        var re = new RegExp(/^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$/g);
        var re1 = new RegExp(/^[-_A-Za-z0-9\.]+@([_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/);
        if (!re.test($("#email").val()) && !re1.test($("#email").val())) {
            alert("请正确输入您的 email 地址！");
            $("#email").focus();
            return false;
        }
        <?php } ?>
                    <?php
                   if (array_key_exists("step", $view) && $view['step'] == "3") {
        ?>
        if ($("#answer").val() == "") {
            alert("请输入您的答案");
            return false;
        }
        <?php }?>
        document.form1.submit();
    }
</script>
</body>
</html>